<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <input v-model="inputValue" @keyup.enter="add">
        <ul>
            <li v-for="(item,index) in li">
                <span>{{index+1}}  {{item}}&nbsp&nbsp&nbsp&nbsp&nbsp</span>
                <button @click="remove(index)" style="background-color: transparent; border:0px">x</button>
            </li>

        </ul>
        <span v-show="li.length!=0">
        记事数：{{li.length}}&nbsp&nbsp&nbsp&nbsp
        <button @click="clear">clear</button>
        </span>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script>
        var app=new Vue({
            el:"#app",
            data:{
                li:['c','c++','java'],
                inputValue:''
            },
            methods:{
                add:function(){
                    this.li.push(this.inputValue)
                },
                remove:function(index){
                    this.li.splice(index,1)/* 删除li索引为index的数据 */
                },
                clear:function(){
                    this.li=[]
                }
            }
        })
    </script>
</body>
</html>